-
Notifications
You must be signed in to change notification settings - Fork 11
playground: Add ability to fix imports via goimports. #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ok, everything is done from my side and this is ready to merge. It can be squashed into fewer commits after review. PTAL. |
What are the changes to the |
From the PR description (with emphasis added):
You can visualize the diff with any tool by comparing the folders of this In summary, it removes some unused code (reducing the functionality to use in-memory pre-computed database of packages only, no falling back to reading from disk), and sets some internal configuration variables. Since those variables not exported, the upstream package cannot be directly used. One alternative I see is not removing the unused code, but copying the upstream func init() {
// Override some internal funcs.
importPathToName = importPathToNameBasic
findImport = findImportStdlib
} Which would make the forked package a little easier to maintain, but it will have a lot of extra unused code and potentially still cause syscall errors.
The problem is that the One idea for how to resolve that upstream is to make a CL that makes the package friendly to such IO-less environments is to make use of the However, even if that happens, I've built a custom index including Go 1.5 standard library and Concluding noteI realize this is a lot of code and it seems hard to maintain. However, I've considered that, and I think it will not cause a lot of problems for these reasons:
|
…packages. Generate zstdlib.go, include Go 1.5, skip syscall. Use a modified version of cmd/api tool to include gopherjs/js package. Add go generate step for imports package to update.sh.
Add ability to turn off goimports. As suggested by @dominikh.
I've squashed and rebased this PR into 4 logical commits, that should be easier to review, maintain and understand in the future. This has LGTM and is ready to merge from my side. |
go func() { | ||
var out []byte | ||
var err error | ||
switch dom.GetWindow().Document().GetElementByID("imports").(*dom.HTMLInputElement).Checked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a better angular way of accessing the value of a checkbox; I do not know what it is, so I just accessed the DOM directly.
@neelance, will you have a chance to review this soon? It's ready to merge from my side. |
I think it is reasonable to ask for |
Factor out []byte(scope.Get("code").String()) into a local variable. Rebuild playground.
I will try, but a few things:
I'll file an issue with the feature request. |
Filed issue golang/go#12696. With that, I've addressed all your outstanding comments. PTAL. |
LGTM :) |
playground: Add ability to fix imports via goimports.
Resolves #29.
This is a WIP, there are still a few things I want to clean up and do. Edit: All done.
gopherjs.com/gopherjs/gopherjs/js
package in the pre-baked list.imports
package code to avoid reading from disk, because some private internal configuration had to be changed to make that work. Just want to confirm that's still the case.pkgIndex
and causes syscall errors in browser environment.imports
package underinternal
subfolder. We probably don't want others to be importing it.However, it's functional and ready for initial review.